Repository navigation
fix(tar-extract): unpack only the manifest's listed paths (CORE-386) - #448
Merged
Merged
Conversation
… other entry (CORE-386) pharn-oss v7.25.3-v7.25.5 commit seven symlinks under .claude/skills/, outside pharn-install.json, and the extractor refused any non-file entry anywhere in the archive, so every init/add/update/status failed on every channel. The extractor now selects, then judges: two streamed passes over the archive write only the files the CLI reads itself (CLONE_READ_FILES) and then, once the manifest has validated, only the paths it lists. Every other entry is skipped and never written, whatever its type or name. A listed path keeps every rule (regular file, strict UTF-8, no control/format char, no absolute/../\/:, one root, no duplicate) and a pax/GNU-modified entry at a listed path is refused; verifyUpstreamManifest still fails a listed file that is missing or altered. The tar is streamed through createGunzip, so the 128 MB cap now bounds bytes written; headers (200k) and decompressed bytes (1 GiB) bound the walk. extractPharnArchive takes a buffer, for a later local verify-archive mode. Docs (CLAUDE.md, architecture, contributing, SECURITY, THREAT-MODEL via the user's patch) and CHANGELOG [Unreleased] updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
🛡️ pharn-ci · ✅ PassTip Pass · Diff coverage of this change is 100% against a threshold of 80%; 33 agent setup files found.
🧪 Diff coverage
100% of changed lines covered (132/132, threshold 80%) Changed files (3)
🔍 Test integrityNo test-integrity findings (mode: block). Tests changed: +25 −0 ~33 · 1 renamed
🤖 Agent setup (33 files)Agent setup: 33 files · amp, claude-code, codex, copilot, cursor, jules, opencode, zed Agent setup files (33)
pharn-ci 0.12.0 · report schema v2 · coverage format lcov |
… (CORE-386) Bump to 0.21.6 (epic-coordinated) and move the CORE-386 entry into the [0.21.6] CHANGELOG section; v0.21.5 joins KNOWN_TAGS. pharn-ci TI02 read the restructured tar-extract tests as removals. The tests keep their base names now (the same behaviour, re-expressed against the selection), with the old merged g-header and BOM cases split back out. The init test is back to its base text: the new marker message still contains it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pharn-ci TI02 still read eight base tests as removed (computed it.each names
match by body). They are back with their base bodies: a test-level LIMITS
selects every path they use (latin1 keys), so each entry is judged by the full
rules exactly as before. A rootless entry named like a selected path is now
refused ("no path below the archive root") rather than skipped, which restores
"rejects a file with no component to strip". CLAUDE.md no longer names
pharn-install.json as a repo path (pharn-ci SETUP_STALE_SI02).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CORE-386)
The refusal of a listed file after a modifier header now names that header's
type through describeTypeflag ("unsupported type 'x' (a pax extended
header, ...)"), so the base pax test keeps its expected value. The base test
"bounds the bytes written by the decompressed size" keeps its name, now over
the streamed decompressed cap (maxScannedBytes).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
pharn-oss v7.25.3–v7.25.5 commit seven symlinks under
.claude/skills/, outsidepharn-install.json.src/lib/tar-extract.tsapplied its strict rules to every archive entry, so everypharn init/add/update/statusfailed on every channel (tar entry has an unsupported type '2': …/.claude/skills/pharn-ci-cover). The same would happen for a hard link, a paxxheader (a path segment over 100 bytes), a:or\in a name, or the repo outgrowing 20,000 entries / 128 MB, anywhere in pharn-oss — though only 616 of its 4,149 files are installed.Select, then judge.
extractPharnArchive(src/lib/repo.ts) makes two streamed passes over the downloaded.tar.gz:CLONE_READ_FILES(pharn-install.json,SKILLS_VERSION,MIN_CLI,.claude/settings.json), run the release check, and validate the manifest through the one parser;verifyUpstreamManifestholds every listed file to its raw sha256, as before.Every other entry is skipped and never written, whatever its type or name. Every header is still framing-checked (checksum,
ustarmagic, octal size, end marker + zero tail). A listed path keeps today's rules: regular file only, strict UTF-8, no control/format character, no absolute /../\/:/ empty segment, one root, and now also no duplicate. A paxx/ GNUL/Kheader is skipped with the entry it modifies; if that entry's ustar name is a listed path it is refused, and if the record renamed a listed file away, that file is missing and the hash check refuses.zlib.createGunzip), never held whole. Caps: 32 MB download (unchanged), 200,000 headers, 1 GiB decompressed bytes walked (compression-bomb bound), 128 MB written.TarExtractErrorkeeps its name/export, and every refusal still names the entry path and the rule (composes with CORE-388's boundary wrapper, fix: name the ref, the fault and the next steps when the pharn-oss archive is refused (CORE-388) #447).extractTarGz(archive: Buffer, dir, { select, limits, root })andextractPharnArchive(archive, dir, checkTree?)take bytes, never a URL, so CORE-387'sverify-archive <file.tar.gz>can run the same walk + hash check with no network.readUpstreamManifestalso accepts a manifest that lists a file underpharn/pharn-contracts/, so the manifest validates between the passes (equivalent once extracted; the hash check proves the file arrived).unsupported type 'x' (a pax extended header, …)).tests/tar-extract.test.tskeeps every base test name and body: a test-levelLIMITSselects every path the base fixtures use, so each is judged exactly as before; new blocks cover the unselected side. The old "rejects a symlink entry outright, rather than skipping it" decision is narrowed, not reversed, with the reason recorded: degit's silent skip lost listed files; now an unlisted entry is skipped unwritten and a listed one is still refused or fails the manifest hash check.tests/project-lock.test.ts: the signal children'ssignalHandledhelper holds the loop open with a ref'd timer. The SIGINT-after-fetch child exited 13 (unsettled top-level await) once extraction became streamed — it had only passed onmainbecause a tsx IPCConnectWraphappened to still be pending. No assertion changed.CLAUDE.md("The clone is data", network bounds),docs/architecture.md,docs/contributing.md,SECURITY.md,THREAT-MODEL.md(applied by the maintainer from a patch script, as it is hook-protected),CHANGELOG.md[0.21.6]section (Fixed + Security). Version 0.21.6 (epic-coordinated: 386 = 0.21.6, 388 = 0.21.7, 387 = 0.22.0);v0.21.5added toKNOWN_TAGS.How tested
x+ renamed entry, GNUL/K,:/\/ invalid-UTF-8 / control-character names, absolute,.., second root and rootless entries all install and write nothing; the same entry at a listed path is refused (or, pax-renamed, fails the hash check intests/repo.test.ts). Plus duplicate, header/scanned/written caps, odd chunk boundaries (1/7/511/513/1500-byte chunks give byte-identical trees), gzip errors, and a repo larger than the written cap./pharn-dev-shipartifacts in.dev/features/core-386-unpack-listed-paths-only/(regressno-regressions, verifyPASS).dist/index.js, in throwaway projects:init --yes→ exit 1,tar entry has an unsupported type '2': pharn-oss-1755d6b…/.claude/skills/pharn-ci-cover;--ref latest→ release v7.25.5, commit1755d6b8, 7 symlinks):init --yesexit 0 (592 files),status"No drift",update --yes"Up to date"; no symlink in the project;--ref main(commita2cacaef, 7 symlinks):init --yesexit 0,status"No drift",update --yes"Up to date"; andupdate --yes --ref mainon the latest install exit 0.Linear: https://linear.app/pharn-dev/issue/CORE-386
🤖 Generated with Claude Code